Install Django on CyberPanel and Openlitespeed with WSGI



Install Django on CyberPanel and Openlitespeed with WSGI

  • Step 1 : Install LiteSpeed Implementation of WSGI
  • Step 2 : Create site:
  • Step 3: Create Virtual Environment
  • Step 4: Install Django
  • Step 5: Create Django Project
  • Step 6: Modify Django settings
  • Step 7: Create context in OpenLiteSpeed
  • Step 8: Verify Django Installation

The setup is with virtual environment.

Step 1 : Install LiteSpeed Implementation of WSGI

Install Python 3 libraries required for compilation

yum update
yum upgrade openlitespeed
yum install python3-devel 
yum install python3-pip
cd ~
curl -O http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.7.tgz

Output:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 48997  100 48997    0     0   130k      0 --:--:-- --:--:-- --:--:--  130k
[root@mail ~]# curl -O http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.7.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 48997  100 48997    0     0   135k      0 --:--:-- --:--:-- --:--:--  135k

Extract tar

tar xf wsgi-lsapi-1.7.tgz
cd wsgi-lsapi-1.7

Configure with Python 3

python3 ./configure.py

Compile

make

Output:

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o main.o main.c
In file included from /usr/include/inttypes.h:25:0,
                 from ./lsapidef.h:37,
                 from ./lsapilib.h:41,
                 from main.c:34:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o wsgi.o wsgi.c
In file included from /usr/include/limits.h:26:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
                 from /usr/include/python3.6m/Python.h:11,
                 from wsgi.c:29:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o wsgiinput.o wsgiinput.c
In file included from /usr/include/limits.h:26:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
                 from /usr/include/python3.6m/Python.h:11,
                 from wsgiinput.c:29:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o wsgiwrapper.o wsgiwrapper.c
In file included from /usr/include/limits.h:26:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
                 from /usr/include/python3.6m/Python.h:11,
                 from wsgiwrapper.c:29:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o lsapilib.o lsapilib.c
In file included from /usr/include/ctype.h:26:0,
                 from lsapilib.c:35:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o lsapi-glue.o lsapi-glue.c
In file included from /usr/include/limits.h:26:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
                 from /usr/include/python3.6m/Python.h:11,
                 from lsapi-glue.c:33:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wl,-z,relro  -g -L/usr/lib64 -Xlinker -export-dynamic -o lswsgi main.o wsgi.o wsgi              input.o wsgiwrapper.o lsapilib.o lsapi-glue.o -L/usr/lib64/python3.6/config-3.6m-x86_64-linux-gn              u -lpython3.6m -lpthread -ldl  -lutil -lm

Copy lswsgi to fcgi-bin

cp lswsgi /usr/local/lsws/fcgi-bin/

if existing overwrite

cp: overwrite ‘/usr/local/lsws/fcgi-bin/lswsgi’? y

Step 2 : Create site:

Login to your CyberPanel Control Panel.




Create website, you can get a new hosting account with Openlitespeed here https://www.hostingbyalitech.com

Fill out :

Site package : default (or any other if you have)

Site owner : yourusername

Domain name : souqagora.tk (here I am using this site this will be referred throughout the tutorial.

E-mail: your e-mail

Select php : 7.3 (this will not affect but normally I choose 7.3 or as required)

and check all additional features i.e. SSL, DKIM Support, open_basedir protection, Create Mail Domain

Step 3: Create Virtual Environment

Move to your site root dir:

cd /home/souqagora.tk/public_html

Create virtual environment:

python3 -m virtualenv /home/souqagora.tk/public_html

Output :

Using base prefix '/usr'
  No LICENSE.txt / LICENSE found in source
New python executable in /home/souqagora.tk/public_html/bin/python3
Also creating executable in /home/souqagora.tk/public_html/bin/python
Installing setuptools, pip, wheel...
done.

Activate virtual environment:

source /home/souqagora.tk/public_html

check python directory

which python

It should reflect the directory of your virtual environment:

/home/souqagora.tk/public_html/bin/python

Step 4: Install Django

pip install django

Output:

Collecting django
  Using cached Django-3.1.6-py3-none-any.whl (7.8 MB)
Collecting sqlparse>=0.2.2
  Using cached sqlparse-0.4.1-py3-none-any.whl (42 kB)
Collecting pytz
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting asgiref=3.2.10
  Using cached asgiref-3.3.1-py3-none-any.whl (19 kB)
Installing collected packages: sqlparse, pytz, asgiref, django
Successfully installed asgiref-3.3.1 django-3.1.6 pytz-2021.1 sqlparse-0.4.1

Step 5: Create Django Project

python3 -m django startproject souq

Note: My project name is souq replace as required.

Step 6: Modify Django settings

cd souq
cd souq
nano settings.py

Change below 

ALLOWED_HOSTS = []

So that it should reflect as:

ALLOWED_HOSTS = ['*']

and add below at the end of the file settings.py

STATIC_ROOT = '/home/souqagora.tk/public_html/souq/public/static'

mentioning /public/static is required

cd..

make sure you are in the below folder:

/home/souqagora.tk/public_html/souq/

Use this command to make sure:

pwd

create directory

mkdir -p public/static

Collect static files:

python manage.py collectstatic

Make database migration

python manage.py migrate

Output:

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK

Create super user:

python manage.py createsuperuser

Output:

Username (leave blank to use 'root'): root
Email address:
Password:
Password (again):
Superuser created successfully.

Note: Here I am creating with root user because I was having difficulties creating other users at the moment. After you create first user with root you may create other users while in Django admin.

Change folder owner:

chown -R nobody:nobody /home/souqagora.tk/public_html/souq/

Step 7: Create context in OpenLiteSpeed

Login to your OpenLiteSpeed Control Panel, 7080 is the Openlitespeed Port for Control Panel:

https://hostingbyalitech.com:7080

Go to Virtual Hosts on side bar.

and open the virtual host configuration form above icon.

Click Context Tab.

Click ‘+’ sign and add new context, select App Server as shown below:

and click next.

Now fillout these details as shown:

URI * = /

Location * = /home/souqagora.tk/public_html/souq/

Binary Path = /usr/local/lsws/fcgi-bin/lswsgi

Application Type = WSGI

Startup File = souq/wsgi.py

Environment = PYTHONPATH=/home/souqagora.tk/public_html/lib/python3.6:/home/souqagora.tk/public_html/souq
LS_PYTHONBIN=/home/souqagora.tk/public_html/bin/python

Note: Make sure you have python version 3.6 otherwise check accordingly and modify above version in PYTHONPATH.

Step 8: Verify Django Installation

http://souqagora.tk/admin/

These links were of help but I had to struggle alot to reach to success which changes have been included in these guides:

https://openlitespeed.org/kb/python-wsgi-applications/

https://blog.cyberpanel.net/2019/01/10/how-to-setup-django-application-on-cyberpanel-openlitespeed/

Keywords:

Install, Django, on, CyberPanel, Openlitespeed, with WSGI, WSGI, Install Django, CyberPanel Django, OpenLitespeed with WSGI

Posted in Technical Solutions on Feb 02, 2021



Generative AI Could Cause 10 Billion iPhones’ Worth of E-Waste Per Year by 2030

Posted in News on Oct 29, 2024

As generative AI technology continues to advance at breakneck speed, researchers warn that the resulting e-waste could be staggering—potentially exceeding the equivalent of 10 billion discarded iPhones annually by 2030. A study by Cambridge University and the Chinese Academy of Sciences predicts that e-waste from AI could soar from approximately 2.6 thousand tons in 2023 to between 400 kilotons and 2.5 million tons in just a few years. This surge highlights the urgent need for proactive measures to manage electronic waste effectively, from implementing circular economy strategies to promoting sustainability in tech practices. The challenge is significant, but with collective action from industry leaders, policymakers, and consumers, we can mitigate the environmental impact of this rapidly evolving technology and pave the way for a greener future.



Tips for Changing Python Django Superuser Password

Posted in Technical Solutions on Jun 07, 2024

Tips for Changing Python Django Superuser Password



New Look with the New Plans...

Posted on Jan 04, 2021

New Look with the New Plans... Buy the hosting which doesn’t only saves you money but also give you extreme performance...



Meta Connect 2024: A Deep Dive into Meta's New AI Features and Llama 3.2

Posted in News on Sep 27, 2024

Meta Connect 2024 unveiled a suite of groundbreaking AI features that are set to reshape user experiences across Meta's apps. At the heart of these innovations is Llama 3.2, Meta’s latest large language model with multimodal capabilities, allowing it to process both text and images. This model powers everything from intuitive image editing to real-time voice interactions and seamless translation. Additionally, Meta's AI Studio lets users create lifelike chatbots, while the introduction of AI-powered voice assistants and real-time dubbing highlights Meta's commitment to pushing the boundaries of artificial intelligence



WordPress Hosting & Management

Posted on Nov 04, 2024

Choosing the right WordPress hosting service is one of the most critical decisions you’ll make when building a website. The hosting provider you select can impact your site’s speed, security, and reliability. With so many options available, understanding the different types of WordPress hosting can help you make an informed choice. This guide will delve into the various aspects of WordPress hosting and management, providing insights that can empower you to create a successful online presence.



CES 2025: Samsung’s AI Robot Ballie Ready to Roll in 2025

Posted in News on Jan 07, 2025

Samsung’s AI-powered robot Ballie, a bright yellow rolling companion, is set to transform smart home technology in 2025. First introduced as a concept in 2020, Ballie combines cutting-edge AI personalization, advanced sensors, and seamless integration with smart home systems. Equipped with a built-in projector and Vision AI, it tailors its functions to suit individual lifestyles. From entertaining with movies and games to controlling devices through voice commands, Ballie acts as a versatile and interactive home assistant. Its official release marks a significant milestone in AI-driven living, offering a glimpse into the future of smarter, more connected homes.



[SOLVED / FIXED] Python Django - TypeError: can't multiply sequence by non-int of type 'float'

Posted in Technical Solutions on Apr 02, 2022

[SOLVED / FIXED] Python Django - TypeError: can't multiply sequence by non-int of type 'float' Error: Language : Python Django TypeError: can't multiply sequence by non-int of type 'float'<strong>SOLUTION / FIX



Oprah’s Upcoming AI Television Special Sparks Outrage Among Tech Critics

Posted in News on Sep 04, 2024

Oprah Winfrey's upcoming AI television special, "AI and the Future of Us," airing on September 12, 2024, has sparked significant controversy. While the show aims to educate viewers about the impact of artificial intelligence, featuring interviews with tech leaders like Sam Altman and Bill Gates, critics argue that it may serve more as a promotional platform for the AI industry than as an unbiased exploration. Concerns have been raised about the potential for bias, with some fearing the show might downplay the ethical, social, and environmental challenges posed by AI.



Amazon Brings Generative AI-Powered Recaps to Prime Video

Posted in News on Nov 05, 2024

Amazon Prime Video has launched X-Ray Recaps, an AI-driven feature that gives viewers quick, spoiler-free summaries of TV episodes or entire seasons. Initially available for U.S. Fire TV users, the feature helps viewers catch up on plot points without revealing future events. Powered by Amazon's AI technology, including Amazon Bedrock and SageMaker, X-Ray Recaps expands on Prime Video’s X-Ray feature, which provides cast info and trivia, by offering precise, real-time plot recaps at any point during viewing.



The Importance of Cybersecurity in the Modern World of Web Hosting and Domain Names

Posted in Uncategorized on Jul 15, 2024

In today's digital age, cybersecurity is vital for protecting web hosting and domain names from various threats such as malware, phishing attacks, and data breaches. This article explores the importance of cybersecurity, offering insights and actionable steps to safeguard your online presence.



ACME now uses ZeroSSL, here is what you need to do for your CyberPanel

Posted in Technical Solutions on Jul 02, 2021

ACME now uses ZeroSSL, here is what you need to do for your CyberPanel.



Choosing an SEO-Friendly Domain Name

Posted in Uncategorized on Jul 30, 2024

Choosing an SEO-friendly domain name is crucial for your website's success. This comprehensive guide explores the importance of domain names in SEO, provides actionable tips for selecting the best domain, and shares strategies to enhance your domain's SEO performance. Discover how to pick the right keywords, the benefits of short and simple domain names, and the role of trustworthy domain extensions. Learn how to create valuable content, build backlinks, and brand your domain effectively. Get insights into competitor domain analysis and whether you need to change your domain name for better SEO results.



[SOLVED / FIXED] LinkedIn Company Page Creation error : An error has occurred, please try again later. Learn more.

Posted on Jun 09, 2021

[FIXED] : LinkedIn Company Page Creation error : An error has occurred, please try again later. Learn more. [SOLUTION]: In order to create a Company Page in LinkedIn you will need to meet all the requirements below.



AI-Generated Captions Come to Max via Google

Posted on Sep 25, 2024

Warner Bros. Discovery has partnered with Google to launch "Caption AI," an innovative tool that uses AI technology to automatically generate captions for unscripted programming on the Max streaming service. Built on Google’s Vertex AI platform, this collaboration aims to cut captioning costs by up to 50% and reduce production time by 80%. As the media industry increasingly embraces AI, this partnership highlights the potential of technology to streamline processes while maintaining quality and accuracy in content accessibility.



Mastering Homework: A Guide to Effective Scheduling

Posted in Uncategorized on Jun 07, 2024

Learn how to schedule homework activities effectively to reduce stress, improve time management, and enhance academic performance



25 AI Tips to Boost Your Programming Productivity with ChatGPT

Posted in News on Nov 19, 2024

In today’s fast-paced programming environment, efficiency is key. With tools like ChatGPT, coding can become faster, smoother, and more effective. Think of AI as a trusty power tool in your development toolkit—it doesn’t build the project for you, but it makes the process much easier. Below, I’ll share 25 actionable tips to leverage ChatGPT and significantly enhance your programming productivity.



Google’s New Verified Checkmarks in Search: A Game-Changer for User Trust

Posted in News on Oct 08, 2024

As we navigate the digital age, online trust has become increasingly important. Google is now experimenting with a feature that aims to strengthen this trust: verified checkmarks in search results. These blue ticks could soon help users easily identify which businesses are legitimate and trustworthy. But what does this mean for the average internet user? Let’s dive deeper into this new feature and explore its implications.



Google Gemini’s Memory Feature: Personalizing AI Interactions

Posted in News on Nov 21, 2024

Google Gemini's new memory feature takes AI personalization to the next level. By allowing users to input specific preferences and details, Gemini tailors its responses to better suit individual needs. Whether it's adjusting to dietary requirements or prioritizing professional interests, this feature offers a more relevant and engaging experience. Unlike other AI systems, Gemini gives users full control over what information is remembered, ensuring privacy and transparency. Available to subscribers of the Google One AI Premium plan, this feature is set to redefine how we interact with AI chatbots.




Other Blogs


Generative AI Could Cause 10 Billion iPhones’ Worth of E-Waste Per Year by 2030

Posted in News on Oct 29, 2024 and updated on Oct 29, 2024

Tips for Changing Python Django Superuser Password

Posted in Technical Solutions on Jun 07, 2024 and updated on Jun 07, 2024

New Look with the New Plans...

Posted on Jan 04, 2021 and updated on Aug 26, 2022

Meta Connect 2024: A Deep Dive into Meta's New AI Features and Llama 3.2

Posted in News on Sep 27, 2024 and updated on Sep 27, 2024

WordPress Hosting & Management

Posted on Nov 04, 2024 and updated on Nov 04, 2024

CES 2025: Samsung’s AI Robot Ballie Ready to Roll in 2025

Posted in News on Jan 07, 2025 and updated on Jan 07, 2025

Oprah’s Upcoming AI Television Special Sparks Outrage Among Tech Critics

Posted in News on Sep 04, 2024 and updated on Sep 04, 2024

Amazon Brings Generative AI-Powered Recaps to Prime Video

Posted in News on Nov 05, 2024 and updated on Nov 05, 2024

Choosing an SEO-Friendly Domain Name

Posted in Uncategorized on Jul 30, 2024 and updated on Jul 30, 2024

AI-Generated Captions Come to Max via Google

Posted on Sep 25, 2024 and updated on Sep 25, 2024

Mastering Homework: A Guide to Effective Scheduling

Posted in Uncategorized on Jun 07, 2024 and updated on Jun 07, 2024

25 AI Tips to Boost Your Programming Productivity with ChatGPT

Posted in News on Nov 19, 2024 and updated on Nov 19, 2024

Google’s New Verified Checkmarks in Search: A Game-Changer for User Trust

Posted in News on Oct 08, 2024 and updated on Oct 08, 2024

Google Gemini’s Memory Feature: Personalizing AI Interactions

Posted in News on Nov 21, 2024 and updated on Nov 21, 2024

New Look with the New Plans...

Posted on Jan 04, 2021

WordPress Hosting & Management

Posted on Nov 04, 2024

New Look with the New Plans...

Posted on Jan 04, 2021

WordPress Hosting & Management

Posted on Nov 04, 2024







Comments

Please sign in to comment!






Subscribe To Our Newsletter

Stay in touch with us to get latest news and discount coupons